home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1992-1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- //////////////////////////////////////////////////////////////////////
- // Render.c++ - implimentation of the render class
- //////////////////////////////////////////////////////////////////////
-
- #include "Render.h"
-
- void init_render()
- {
- init_colormaps();
-
- // set up lighting
- static float grey_plastic[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.5, 0.5, 0.5,
- SPECULAR, 0.8, 0.8, 0.8,
- SHININESS, 10.0,
- LMNULL};
-
- static float blue_plastic[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.1, 0.1, 0.5,
- SPECULAR, 0.4, 0.4, 0.4,
- SHININESS, 10.0,
- LMNULL};
-
- static float black_plastic[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.1, 0.1, 0.1,
- SPECULAR, 0.4, 0.4, 0.4,
- SHININESS, 10.0,
- LMNULL};
-
- static float charcoal[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.3, 0.3, 0.3,
- SPECULAR, 0.5, 0.5, 0.5,
- SHININESS, 20.0,
- LMNULL};
-
- static float asphalt[] = {
- DIFFUSE, 0.05, 0.05, 0.05,
- LMNULL};
-
- static float yellow_asphalt[] = {
- DIFFUSE, 0.8, 0.8, 0.0,
- SPECULAR, 0.1, 0.1, 0.0,
- SHININESS, 1.0,
- LMNULL};
-
- static float white_metal[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.7, 0.7, 0.8,
- SPECULAR, 0.8, 0.8, 0.8,
- SHININESS, 30.0,
- LMNULL};
-
- static float red_metal[] = {
- AMBIENT, 0.5, 0.0, 0.0,
- DIFFUSE, 0.7, 0.0, 0.0,
- SPECULAR, 1.0, 1.0, 1.0,
- SHININESS, 50.0,
- LMNULL};
-
- static float chrome[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.6, 0.6, 0.6,
- SPECULAR, 0.8, 0.8, 0.8,
- SHININESS, 30.0,
- LMNULL};
-
- static float grey_rubber[] = {
- AMBIENT, 0.2, 0.2, 0.2,
- DIFFUSE, 0.5, 0.5, 0.5,
- LMNULL};
-
- static float wood[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.46, 0.29, 0.0,
- LMNULL};
-
- static float leaves[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.0, 0.8, 0.1,
- LMNULL};
-
- static float grey_metal[] = {
- AMBIENT, 0.2, 0.2, 0.2,
- DIFFUSE, 0.5, 0.5, 0.5,
- SPECULAR, 1.0, 1.0, 1.0,
- SHININESS, 50.0,
- LMNULL};
-
- static float dome_light[] = {
- LCOLOR, 1.0, 1.0, 1.0,
- POSITION, 0.0, 1.0, 1.0, 0.0,
- LMNULL};
-
- static float sun[] = {
- AMBIENT, 0.3, 0.3, 0.3,
- LCOLOR, 1.0, 1.0, 1.0,
- POSITION, 1.0, 0.7, 0.3, 0.0,
- LMNULL};
-
- lmdef(DEFLMODEL, 1, 0, (float *)NULL);
-
- lmdef(DEFLIGHT, SUN, np(sun), sun);
- lmdef(DEFLIGHT, DOME_LIGHT, np(dome_light), dome_light);
-
- lmdef(DEFMATERIAL, GREY_PLASTIC, np(grey_plastic), grey_plastic);
- lmdef(DEFMATERIAL, BLACK_PLASTIC, np(black_plastic), black_plastic);
- lmdef(DEFMATERIAL, RED_METAL, np(red_metal), red_metal);
- lmdef(DEFMATERIAL, CHROME, np(chrome), chrome);
- lmdef(DEFMATERIAL, CHARCOAL, np(charcoal), charcoal);
- lmdef(DEFMATERIAL, ASPHALT, np(asphalt), asphalt);
- lmdef(DEFMATERIAL, YELLOW_ASPHALT, np(yellow_asphalt), yellow_asphalt);
- lmdef(DEFMATERIAL, GREY_RUBBER, np(grey_rubber),grey_rubber);
- lmdef(DEFMATERIAL, WOOD, np(wood), wood);
- lmdef(DEFMATERIAL, LEAVES, np(leaves), leaves);
- lmdef(DEFMATERIAL, GREY_METAL, np(grey_metal), grey_metal);
-
-
- // initialize the font manager
- fminit();
-
- // initialize patterns
- static unsigned short holes1[16] = {
- 0x5555, 0xAAAA, 0x5555, 0xAAAA,
- 0x5555, 0xAAAA, 0x5555, 0xAAAA,
- 0x5555, 0xAAAA, 0x5555, 0xAAAA,
- 0x5555, 0xAAAA, 0x5555, 0xAAAA};
-
- /*
- static unsigned short holes2[16] = {
- 0x3333, 0xCCCC, 0x3333, 0xCCCC,
- 0x3333, 0xCCCC, 0x3333, 0xCCCC,
- 0x3333, 0xCCCC, 0x3333, 0xCCCC,
- 0x3333, 0xCCCC, 0x3333, 0xCCCC};
- */
-
- defpattern(HOLES, 16, holes1);
- }
-
-
-
- // sweeps the segment defined by r-s counter-clockwise by angle
- void sweep(float r[2], float s[2], float angle)
- {
- float last_p[2], last_q[2];
-
- last_p[0] = r[0];
- last_p[1] = r[1];
- last_q[0] = s[0];
- last_q[1] = s[1];
-
- for (float theta = 1.0; theta <= angle; theta += 1.0)
- {
- float p[2], q[2];
-
- float cos = fcos(theta*M_PI/180.0);
- float sin = fsin(theta*M_PI/180.0);
-
- p[0] = r[0]*cos - r[1]*sin;
- p[1] = r[0]*sin + r[1]*cos;
-
- q[0] = s[0]*cos - s[1]*sin;
- q[1] = s[0]*sin + s[1]*cos;
-
- bgnpolygon();
- v2f(last_q);
- v2f(last_p);
- v2f(p);
- v2f(q);
- endpolygon();
-
- last_p[0] = p[0];
- last_p[1] = p[1];
- last_q[0] = q[0];
- last_q[1] = q[1];
- }
- }
-
- void init_colormaps()
- {
- // set up overlay colors
- drawmode(PUPDRAW);
- mapcolor(CLEAR, 0, 0, 0);
- mapcolor(GREY1, 64, 64, 64);
- mapcolor(GREY2, 127, 127, 127);
- mapcolor(GREY3, 192, 192, 192);
- drawmode(NORMALDRAW);
-
- }
-
-
- void vertex(float a, float b)
- {
- float v[2];
- v[0] = a; v[1] = b;
- v2f(v);
- }
-
-